package com.heima.admin.controller;

import com.heima.admin.anno.Log;
import com.heima.api.wemedia.WemediaFeign;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.dtos.SensitivePageDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Slf4j
@Api(tags = "敏感词相关接口")
@RequiredArgsConstructor
public class AdminSensitiveController {
    private final WemediaFeign wemediaFeign;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult queryPageSensitive(@RequestBody SensitivePageDto dto){
        return wemediaFeign.queryPageSensitive(dto);
    }

    /**
     * 添加
     * @param dto
     * @return
     */
    @Log
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody SensitiveDto dto){
        return wemediaFeign.addSenistove(dto);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    @Log
    public ResponseResult deleteSensitive(@PathVariable String id){
        return wemediaFeign.deleteSensitive(id);
    }

    /**
     * 修改
     * @param dto
     * @return
     */
    @Log
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody SensitiveDto dto){
        return wemediaFeign.modifySensitive(dto);
    }
}
